import { _decorator, Component, Node, tween, v3 } from 'cc';
import { Battle } from './Battle';
const { ccclass, property } = _decorator;

@ccclass('Gun')
export class Gun extends Component {


    gunAngle: number = 0;

    protected onEnable(): void {
    }
    start() {

    }

    update(deltaTime: number) {
        if (Battle.playerNode) {
            
            this.node.setWorldPosition(Battle.playerNode.getWorldPosition().x, Battle.playerNode.getWorldPosition().y - 18, Battle.playerNode.getWorldPosition().z);
            this.node.setScale(Battle.playerNode.getScale());
            this.node.angle = this.gunAngle;
            if (Math.abs(this.node.angle) > 90) {
                this.node.setScale(1, -1);
            }
        }
    }

    
}


